package com.rain.cy.business.model.dto;

import lombok.Data;
import org.assertj.core.util.Lists;

import java.util.List;

/**
 * 饼状图
 *
 * @author yu_chen
 * @since 2021/10/7 23:07
 */
@Data
public class CountDataPieDTO {

    private List<CountDataPieItem> countDataPieItemList;


    public CountDataPieDTO append(String name, Integer value) {
        if (this.countDataPieItemList == null) {
            this.countDataPieItemList = Lists.newArrayList();
        }
        this.countDataPieItemList.add(CountDataPieItem.of(name, value));
        return this;
    }

    @Data
    public static class CountDataPieItem {
        private String name;
        private Integer value;

        public static CountDataPieItem of(String name, Integer value) {
            CountDataPieItem countDataPieItem = new CountDataPieItem();
            countDataPieItem.setName(name);
            countDataPieItem.setValue(value);
            return countDataPieItem;
        }
    }


}
